﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EntityPersistorFactory.cs" company="Data Ductus Malmö">
//   (c) 2010 - 2012 Data Ductus Malmö AB
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace DataDuctus.Snmp.Persistor.Core.Persistor
{
  using System.Collections.Generic;

  using DataDuctus.Snmp.Persistor.Core.Agent;
  using DataDuctus.Snmp.Persistor.Core.MetaData;

  /// <summary>
  /// The entity persistor factory.
  /// </summary>
  public sealed class EntityPersistorFactory
  {
    #region Constructors and Destructors

    /// <summary>
    /// Initializes a new instance of the <see cref="EntityPersistorFactory"/> class.
    /// </summary>
    /// <param name="configuration">
    /// The configuration.
    /// </param>
    /// <param name="connection">
    /// The connection.
    /// </param>
    public EntityPersistorFactory(Configuration configuration, IEnumerable<ConnectionMeta> connection)
    {
      this.Config = configuration;
      this.Connection = connection;
    }

    #endregion

    #region Public Properties

    /// <summary>
    /// Gets the config.
    /// </summary>
    public Configuration Config { get; private set; }

    /// <summary>
    /// Gets the connection.
    /// </summary>
    public IEnumerable<ConnectionMeta> Connection { get; private set; }

    #endregion

    #region Public Methods and Operators

    /// <summary>
    /// The open agent session.
    /// </summary>
    /// <returns>
    /// The SnmpPersistor.Core.Agent.AgentSession.
    /// </returns>
    public AgentSession OpenAgentSession()
    {
      return new AgentSession(this, this.Connection);
    }

    /// <summary>
    /// The open session.
    /// </summary>
    /// <returns>
    /// The SnmpPersistor.Core.Persistor.EntitySession.
    /// </returns>
    public EntitySession OpenSession()
    {
      return new EntitySession(this, this.Connection);
    }

    #endregion
  }
}